import request from "@/utils/request.ts";
import React from "react";
import {ICommonResponse} from "@/global.ts";
import {ExcalidrawElement} from "@excalidraw/excalidraw/types/element/types";

export interface DataType {
    key: React.Key;
    flowUID: string;
    userUID: number;
    path: string;
    name: string
    describe: string
    time: string
}

export const flowList = (): Promise<ICommonResponse<Array<DataType>>> => {
    return request({
        url: '/file/flowList',
        method: 'POST'
    })
}

export const flowView = (data: { flowUID: string }): Promise<ICommonResponse<DataType>> => {
    return request({
        url: '/file/flow/view',
        method: 'POST',
        data
    })
}

export const flowJson = (url: string): Promise<Array<ExcalidrawElement>> => {
    return request({
        url,
        method: 'GET'
    })
}

export const flowDel = (data: { flowUID: string, path: string }): Promise<ICommonResponse<{ msg: string }>> => {
    return request({
        url: '/file/flow/del',
        method: 'POST',
        data
    })
}